<?php

	namespace App\Service\Approval\ApprovalCreditProject;

	use App\Service\Approval\DingTalkApprovalInterFace;
    use App\Models\modelCreditProjectManage;
	use App\Tools\Log\Log;

	class ApprovalCreditProjectCreditManagerReview implements DingTalkApprovalInterFace
	{
		public function __construct()
		{
			$this->m_cHelper = app()->gcHelper;
		}

		public function approvalStart($processInstanceId,$sourceId,$processStatus)
		{
			# 审批开始	=> [ 信用项目审批第一节点信控专员审查 ]
			#
			$this->m_cHelper->gfDbQuery()->updateByArrayWithWhere	(
																		$this->m_cHelper->gfGetTableNameByConstKey('CY_CREDIT_PROJECT_EX_TABLE_NAME')
																		,
																		["where id=?",[$sourceId]]
																		,
																		[
																			'credit_project_status'	=> modelCreditProjectManage::CREDIT_PROJECT_STATUS_3_CREDIT_MANAGER_REVIEW
																		]
																		,true
																	);
		
			$this->m_cHelper->gfDebugPrintToLocalFile(self::class."->approvalStart : ".$sourceId,kill:false);
		}

		public function approvalAgreeEnd($processInstanceId, $sourceId,$processStatus)
		{
			# 审批完成
			#
			# $this->m_cHelper->gfDebugPrintToLocalFile(self::class.'->approvalAgreeEnd () : $processInstanceId ='.$$processInstanceId.' $sourceId ='.$sourceId.' $processStatus ='.$processStatus,kill:false);
		}

		public function approvalRefuseEnd($processInstanceId,$sourceId,$processStatus)
		{
			# 审批失败
			# 
			$this->m_cHelper->gfDbQuery()->updateByArrayWithWhere	(
																		$this->m_cHelper->gfGetTableNameByConstKey('CY_CREDIT_PROJECT_EX_TABLE_NAME')
																		,
																		["where id=?",[$sourceId]]
																		,
																		[
																			'credit_project_status'	=> modelCreditProjectManage::CREDIT_PROJECT_STATUS_6_REVIEW_REJECT
																		]	
																	);

		}
	}